{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "0dd77ba1",
   "metadata": {},
   "source": [
    "*本讲义的设计人员：徐志超\n",
    "\n",
    "*撰写日期：2021-10-26\n",
    "\n",
    "*数字媒体技术专业\n",
    "\n",
    "---------------------\n",
    "# 本周学习内容\n",
    "## 1.[github](https://github.com/)的相关知识和实践如何在GitHub上面搜索内容（all github）\n",
    "## 2.再次尝试[gitee](https://gitee.com/)上传文件，并且在上传的时候写一段文字描述\n",
    "<<< 1.本周的电子线上讲义(https://gitee.com/xzhichao/interactive-media-production/tree/master/week03)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "519809db",
   "metadata": {},
   "source": [
    "## 3.课本项目直接运行（page-4）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "deeccd2e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This minute seems a little odd.\n"
     ]
    }
   ],
   "source": [
    "            # 1.课本项目直接运行\n",
    "# 先找到模块，然后从模块中调用一个方法;from模块名字 import 模块方法 \n",
    "from datetime import datetime\n",
    "\n",
    "odds = [  1, 3,  5,  7,  9, 11,13,15,17,19,\n",
    "             21,23,25,27,29,31,33,35,37,39,\n",
    "             41,43,45,47,49,51,53,55,57,59]\n",
    "\n",
    "current_localtime_minute = datetime.today().minute # 一直在变化的当前时间的   分钟数\n",
    "\n",
    "if current_localtime_minute in odds:\n",
    "    # if 语句的子程序 会自动空 Tab键的间隔，如果没有空，不符合语法规则\n",
    "    # if 语句子程序不能为空，也就是至少要有一行子程序，如果还不清楚要写的子程序，可以使用\n",
    "    # pass\n",
    "    print(\"This minute seems a little odd.\")\n",
    "else:\n",
    "    print(\"Not an odd minute.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "ce5d0870",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "140721707100496\n"
     ]
    }
   ],
   "source": [
    "print(id(current_localtime_minute)) #存储地址"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d9191498",
   "metadata": {},
   "source": [
    "## 变量\n",
    "> 1.变量的概念\n",
    ">>***变量**用于存储在计算机程序中引用和操作的信息。它们还提供了一种用描述性名称标记数据的方法，以便读者和我们自己能够更清楚地理解我们的程序。将变量看作包含信息的容器是有帮助的。它们的唯一目的是在内存中标记和存储数据。然后可以在整个程序中使用这些数据。\n",
    "-----\n",
    "> 2.**变量名称**的规范\n",
    ">> 1.变量名称只可以用**数字、字母和下划线**来定义名称\n",
    "\n",
    ">> 2.数字不可以作为变量名的第一个字符 （stu10001）\n",
    "\n",
    ">> 3.内部（开发团队）已经使用过的名称不可以作为变量名,例如：['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda','not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield']\n",
    "\n",
    ">> 4.如果你实在想定义一个已经被用过名字：global_zhichao \\ print_zhichao"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "12595f8b",
   "metadata": {},
   "source": [
    "##  赋值\n",
    "\n",
    ">符号（不同与数学概念的“等于”）: =\n",
    ">右侧为值，左侧为赋予的变量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "93a04dc5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = 1\n",
    "y = 2\n",
    "x + y"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1cb9e2fd",
   "metadata": {},
   "source": [
    "# 变量和赋值 深层理解"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "d60ec239",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "李华\n",
      "李华\n",
      "小红\n",
      "李华\n"
     ]
    }
   ],
   "source": [
    "name_01 = \"李华\"\n",
    "name_02 = name_01\n",
    " # 变量“名”不会进行信息交换，我们只是交换或者传递变量的内容\n",
    "print(name_01)\n",
    "print(name_02)\n",
    "\n",
    "name_01 = \"小红\"\n",
    "\n",
    "# 变量： 可以改变的值，赋值是改变的常用手段\n",
    "# Python是解释性语言,是一行一行执行的，没有特定的要求，是不会重复运行上一行代码的\n",
    "print(name_01)\n",
    "print(name_02)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e22f5d2d",
   "metadata": {},
   "source": [
    "## 基本的数据结构\n",
    "> 1.字符串（strings）\n",
    ">>1.[基本概念]https://docs.python.org/3/tutorial/introduction.html#strings\n",
    ">>>*Besides numbers, Python can also manipulate strings, which can be expressed in several ways. They can be enclosed in single quotes ('...') or double quotes (\"...\") with the same result 2. \\ can be used to escape quotes:\n",
    "```\n",
    ">>> 'spam eggs'  # single quotes\n",
    "'spam eggs'\n",
    ">>> 'doesn\\'t'  # use \\' to escape the single quote...\n",
    "\"doesn't\"\n",
    ">>> \"doesn't\"  # ...or use double quotes instead\n",
    "\"doesn't\"\n",
    ">>> '\"Yes,\" they said.'\n",
    "'\"Yes,\" they said.'\n",
    ">>> \"\\\"Yes,\\\" they said.\"\n",
    "'\"Yes,\" they said.'\n",
    ">>> '\"Isn\\'t,\" they said.'\n",
    "'\"Isn\\'t,\" they said.'\n",
    "```\n",
    ">>2.[基本语法](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "39a87e5a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# SyntaxError: invalid syntax 语法错误，主要形式：符号没有用英文，或者Python语法写错\n",
    "\"doesn't\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "d1157888",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# \\ 用来转义的，后面的符号将作为符号\n",
    "'doesn\\'t'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "5027f12b",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 三引号的优势: 存较为复杂格式的字符串\n",
    "python_str = '''\n",
    "'spam eggs'\n",
    ">>> 'doesn\\'t'  # use \\' to escape the single quote...\n",
    "\"doesn't\"\n",
    ">>> \"doesn't\"  # ...or use double quotes instead\n",
    "\"doesn't\"\n",
    ">>> '\"Yes,\" they said.'\n",
    "'\"Yes,\" they said.'\n",
    ">>> \"\\\"Yes,\\\" they said.\"\n",
    "'\"Yes,\" they said.'\n",
    ">>> '\"Isn\\'t,\" they said.'\n",
    "'\"Isn\\'t,\" they said.'\n",
    "'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "7ff841a3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "'spam eggs'\n",
      ">>> 'doesn't'  # use ' to escape the single quote...\n",
      "\"doesn't\"\n",
      ">>> \"doesn't\"  # ...or use double quotes instead\n",
      "\"doesn't\"\n",
      ">>> '\"Yes,\" they said.'\n",
      "'\"Yes,\" they said.'\n",
      ">>> \"\"Yes,\" they said.\"\n",
      "'\"Yes,\" they said.'\n",
      ">>> '\"Isn't,\" they said.'\n",
      "'\"Isn't,\" they said.'\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(python_str)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "c8803432",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 加入我们想在python 的变量中存HTML（其他的语言），就可以用\"\"\"···\"\"\"\n",
    "evenchan_blog =\"\"\"\n",
    "<meta content=\"IE=edge\" http-equiv=\"X-UA-Compatible\" />\n",
    "<meta name=\"csrf-param\" content=\"authenticity_token\" />\n",
    "<meta name=\"csrf-token\" content=\"c7Unm8G9mVGnWYE4xCxz8kfxm5btMi8jyzofrTD9sOpnXnLlJjCSwXDUeoIpisYwhzCRDTR9uRAGi1nFzDn2Nw==\" />\n",
    "\n",
    "<link rel=\"stylesheet\" media=\"all\" href=\"https://assets.gitee.com/assets/application-49af402616e08d245c067c3fe86cbe1e.css\" />\n",
    "<script>\n",
    "//<![CDATA[\n",
    "\"\"\"\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "6be01dd1",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "<meta content=\"IE=edge\" http-equiv=\"X-UA-Compatible\" />\n",
      "<meta name=\"csrf-param\" content=\"authenticity_token\" />\n",
      "<meta name=\"csrf-token\" content=\"c7Unm8G9mVGnWYE4xCxz8kfxm5btMi8jyzofrTD9sOpnXnLlJjCSwXDUeoIpisYwhzCRDTR9uRAGi1nFzDn2Nw==\" />\n",
      "\n",
      "<link rel=\"stylesheet\" media=\"all\" href=\"https://assets.gitee.com/assets/application-49af402616e08d245c067c3fe86cbe1e.css\" />\n",
      "<script>\n",
      "//<![CDATA[\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(evenchan_blog)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "230df65d",
   "metadata": {},
   "source": [
    "### 字符串的拼接\n",
    "·字符串可以用+运算符连接（粘合在一起）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "946367fd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Li Hua'"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "first_name =\"Li\"\n",
    "last_name = \"Hua\"\n",
    "name = first_name + ' ' + last_name\n",
    "name\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "73fde72e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Li'"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "name[0:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "cface284",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Python'"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'Py' 'thon'"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ea49fc02",
   "metadata": {},
   "source": [
    "·字符串可以被索引index（下标），第一个字符的索引为0。没有单独的字符类型；一个字符只是一个大小为1的字符串；"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "2dc647ad",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "L\n",
      "i\n",
      " \n"
     ]
    }
   ],
   "source": [
    "print(name[0])\n",
    "print(name[1])\n",
    "print(name[2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "1a3333ef",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Li'"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "name[0] +name [1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "3d725707",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'interactive-media-production'"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 练习 取出课程中的“media”\n",
    "course_name = \"interactive-media-production\"\n",
    "course_name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "fac5506e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'i'"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "course_name[-3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "11322b3c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'med'"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 一个一个值得取值方式叫做： index （索引）\n",
    "course_name[12] + course_name[13] +course_name [14]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "5449ef3b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'media'"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 一次性取值的方法： slice （切片） 取左（闭区间）不取右（开区间）\n",
    "course_name[12:17]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "bb4b44b7",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "+---+---+---+---+---+---+\n",
      " | P | y | t | h | o | n |\n",
      " +---+---+---+---+---+---+\n",
      " 0   1   2   3   4   5   6\n",
      "-6  -5  -4  -3  -2  -1\n"
     ]
    }
   ],
   "source": [
    "print(\"\"\"+---+---+---+---+---+---+\n",
    " | P | y | t | h | o | n |\n",
    " +---+---+---+---+---+---+\n",
    " 0   1   2   3   4   5   6\n",
    "-6  -5  -4  -3  -2  -1\"\"\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d293c6a4",
   "metadata": {},
   "source": [
    "## 数值（numbers）\n",
    "· 用来运算的"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "00f67b19",
   "metadata": {},
   "source": [
    "1.数值概念"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "e69346cd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "16"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "9+7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "d2e3483c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "66666"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "12345+54321"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "id": "0b12c488",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1075499496"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "16732*64278"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "a3f86675",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "340282366920938463463374607431768211456"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "2**128"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b143b2fb",
   "metadata": {},
   "source": [
    "### 数值的类型\n",
    "> 1. 整数（int）\n",
    "> 2. 浮点数（float）\n",
    "> 3. 复数（complex）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "id": "c988c6b8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "210"
      ]
     },
     "execution_count": 82,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "210"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "0d68c357",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'int'>\n"
     ]
    }
   ],
   "source": [
    "print(type(210))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c1bd0e33",
   "metadata": {},
   "outputs": [],
   "source": [
    "3.1415926"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "id": "491fad0f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'float'>\n"
     ]
    }
   ],
   "source": [
    "print(type(3.1415916))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5bd8ae7d",
   "metadata": {},
   "outputs": [],
   "source": [
    "3 + 4j"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "id": "b1f40ed4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'complex'>\n"
     ]
    }
   ],
   "source": [
    "print(type(3 + 4j))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5c7556c6",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "64c546c5",
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'pd' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-32-38e525706dc1>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[1;31m# 运算符的所有的 内容\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mpd\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mread_html\u001b[0m \u001b[1;33m(\u001b[0m\u001b[1;34m'https://docs.python.org/3/library/stdtypes.html'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m: name 'pd' is not defined"
     ]
    }
   ],
   "source": [
    "# 运算符的所有的 内容\n",
    "pd.read_html ('https://docs.python.org/3/library/stdtypes.html')[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d2c6ca48",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ce9fda12",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
